<template>
  <div class="search">
    <span class="img" v-if="manst" @click="backtrack"
      ><img src="../assets/syb.png" alt=""
    /></span>
    <div class="shos">
      <van-search
        v-model="value"
        show-action
        shape="round"
        placeholder="请输入搜索关键词"
        :disabled="jingzi"
        @focus="jujiao"
        @click="toSearch"
      >
        <template #action>
          <div @click="onSearch">搜索</div>
        </template>
      </van-search>
    </div>
  </div>
</template>

<script>
import { Search } from "vant";

export default {
  name: "search",
  props: ["vlua"],
  components: {
    [Search.name]: Search,
  },
  data() {
    return {
      value: "",

      // 显示隐藏返回箭头
      manst: true,
      path: ["home", "my", "classify"],
      jingzi: true,
    };
  },
  watch: {
    vlua(e) {
      this.value = e;
    },
  },
  created() {
    this.ReturnsArrow();
  },
  mounted() {
    if (this.$route.name == "search") {
      this.jingzi = false;
    } else {
      this.jingzi = true;
    }
  },
  methods: {
    onSearch() {},
    // 判断要不要返回按键
    ReturnsArrow() {
      // console.log(this.$route.name);
      for (let index = 0; index < this.path.length; index++) {
        if (this.path[index] == this.$route.name) {
          this.manst = false;
        }
      }
    },
    // 点击按钮返回
    backtrack() {

       this.$emit('getTreeData',true);


      // if (
      
       
       
      //   this.$route.name == "orderform" ||
      //   this.$route.name == "evaluate"
      // ) {
      //   this.$router.push("/my");
      // } else {
      //   this.$router.go(-1);
      // }
    },
    toSearch() {
      if (this.$route.name != "search") {
        this.$router.push("/search");
      }
    },
    jujiao() {
      this.hint = "取消";
    },
  },
};
</script>
 
<style lang="less" scoped>
.search {
  display: flex;
  width: 100%;
  align-items: center;
  background: rgb(255, 255, 255);
  .shos {
    flex: 1;
  }
}
.img {
  height: 20px;
  display: block;
  width: 20px;
  img {
    width: 100%;
    height: 100%;
  }
}
</style>